package com.dlkj.threadPool.core.response;

import com.dlkj.threadPool.core.constants.StatusConstant;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @Author : lei
 * @Company ：DiLang Technology
 * @Date : 2018/8/23 16:09
 * @Description : ajax调用返回类
 **/
@Data
@AllArgsConstructor
public class CallResult {
    private Integer code;
    private String msg;
    private Object data;


    public CallResult(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public CallResult(Integer code , String msg){
        this.code = code;
        this.msg = msg;
    }

    public static CallResult callSuccess(String msg){
        return new CallResult(StatusConstant.STATUS_SUCCESS,msg);
    }

    public static CallResult callSuccess(Object data){
        return new CallResult(StatusConstant.STATUS_SUCCESS,data);
    }

    public static CallResult callSuccess(String msg,Object data){
        return new CallResult(StatusConstant.STATUS_SUCCESS,msg,data);
    }

    public static CallResult callFail(String msg) {
        return new CallResult(StatusConstant.STATUS_FAIL,msg);
    }

    public static CallResult callError(String msg) {
        return new CallResult(StatusConstant.STATUS_ERROR,msg);
    }
}
